﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Spaanjaars.ContactManager.Model;

namespace Spaanjaars.ContactManager.Repository.NH.MappingFiles
{
    public class ContactPersonAddressMap : ClassMap<ContactPersonAddress>
    {
        public ContactPersonAddressMap()
        {
            Table("Addresses");
            Not.LazyLoad();
            Id(a => a.Id);
            Component(cpa => cpa.Address, address =>
            {
                address.Map(a => a.HouseNumber);
                address.Map(a => a.Street);
                address.Map(a => a.City);
                address.Map(a => a.ZipCode);
                address.Map(a => a.Country);
            });
           
            HasOne(a => a.ContactPerson)
                .ForeignKey("ContactPersonId");
        }
    }
}
